using System.Collections.Generic;
using System.Collections.Specialized;

namespace AiFrame.InterfaceLib.Data.Patterns
{
    /// <summary>
    /// Outlines the behavior that the user and persistent notifying list collections 
    /// will exhibit.
    /// </summary>
    /// <remarks>
    /// When using this collection type in an application with an NHibernate back-end, this 
    /// interface should be used as the declaring type for any class members in which the 
    /// desired type is <see cref="HibernateObservableList{T}<T>"/>.  NHibernate will provide an instance
    /// of the <see cref="PersistentGenericObservableBag{T}<T>"/> persistent wrapper class if the
    /// collection has been persisted.
    /// </remarks>
    /// <typeparam name="T">Type of item to be stored in the list.</typeparam>
    public interface IObservableList<T> : IList<T>, ISortableList<T>, INotifyCollectionChanged
    {
        /// <summary>
        /// Deletes all elements and fills the list with the given
        /// elements.
        /// </summary>
        /// <param name="list">The new elements.</param>
        void Fill(IObservableList<T> list);

        /// <summary>
        /// Begins the update process. During an update process 
        /// no events are fired when contents are changed.
        /// </summary>
        void BeginUpdate();

        /// <summary>
        /// Ends the update process.
        /// </summary>
        void EndUpdate();

        /// <summary>
        /// Sorts the list with the given comparer.
        /// </summary>
        /// <param name="comparer">The comparer.</param>
        void Sort(IComparer<T> comparer);

        /// <summary>
        /// Replaces a object with the given object.
        /// </summary>
        /// <param name="obj">The object which has to be replaced.</param>
        void Replace(T obj);

        /// <summary>
        /// Invokes a notification event that the list has changed.
        /// </summary>
        void InvokeNotificationEvent();
    }
}